package cvar.model;

import java.util.List;
import java.util.Map;

public class LPModel {

  
  private final Variable[] variables_;
  private final double[] weights_;
  private final List<Constraint> ieqs_;
  private final List<Constraint> eqs_;
  private final Map<Variable, Integer> index_;

  LPModel(Variable[] variables, double[] weights,
      List<Constraint> ieqs, List<Constraint> eqs, Map<Variable, Integer> index) {
    variables_ = variables;
    ieqs_ = ieqs;
    eqs_ = eqs;
    weights_ = weights;
    index_ = index;
  }

  public Variable[] getVariables() {
    return variables_;
  }

  public List<Constraint> getEqualities() {
    return eqs_;
  }

  public List<Constraint> getInequalities() {
    return ieqs_;
  }
  
  public int getVariableIndex(Variable x) {
    return index_.get(x);
  }

  public int numNotNullAValues() {
    int sum = 1;
    for (Constraint ieq : ieqs_) {
      sum += ieq.getNotNullVariables().size();
    }
    for (Constraint ieq : eqs_) {
      sum += ieq.getNotNullVariables().size();
    }
    return sum;
  }

  public double[] getVariableWeights() {
    return weights_;
  }

}
